Interrupt Handling & Scheduling.md (1303B)
1 +++ 2 title = 'Interrupt Handling & Scheduling' 3 +++ 4 # Interrupt Handling & Scheduling 5 6 interrupt handling: 7 - deallocate CPU and give it to the scheduler. we rely on hardware-provided interrupt handling support (like a notification). 8 - allows scheduler to periodically get control whenever hardware generates an interrupt 9 - interrupt vector: 10 - associated with each IO device and interrupt line 11 - part of Interrupt descriptor table (IDT) 12 - contains start address of OS-provided internal procedure 13 - interrupt handler continues execution 14 - interrupt types: 15 - software: synchronous e.g. interrupt (int \$0x80) 16 - hardware device: asynchronous, e.g. exceptions 17 18 The scheduler gets control every time an interrupt occurs. It acts as a mediator. 19 20 What happens? 21 1. Hardware puts program counter etc. on the stack 22 2. Hardware loads new program counter from interrupt vector 23 3. Assembly language procedure saves registers 24 4. Assembly language procedure sets up new stack 25 5. C interrupt service runs (e.g. reads and buffers input) 26 6. Scheduler decides which process is to run next. 27 7. C procedure returns to assembly code. 28 8. Assembly language procedure starts up new current process 29 30 A process can't give the CPU to another process (i.e. do a context switch) without going through the scheduler.